import { nextTick } from "vue";
let getHeight=(tableHeight: any, subHeightNum:any,parentClassNameOrId:any)=>{
    let tableHeightNum;
    let parentHtmlEle = document.getElementById(parentClassNameOrId)
    parentHtmlEle = parentHtmlEle ? parentHtmlEle : document.getElementsByClassName(parentClassNameOrId)[0] as HTMLElement;
    nextTick(()=>{
        debugger
        tableHeightNum = parentHtmlEle ? parentHtmlEle.offsetHeight  - subHeightNum : 0;   
        tableHeight.value.y = tableHeightNum
    })
    return tableHeight;
}

const dateFormater = function(date:Date,fmt:string){
    let o = {
        "M+":date.getMonth()+1,
        "d+":date.getDate(),
        "h+":date.getHours()%12==0 ? 12 : date.getHours()%12,
        "H+":date.getHours(),
        "m+":date.getMinutes(),
        "s+":date.getSeconds(),
        "q+":Math.floor((date.getMonth()+3)/3), //季度
        "S+":date.getMilliseconds(),
    }
    let week = {
        "0":"/u65e5",
        "1":"/u4e00",
        "2":"/u4e8c",
        "3":"/u4e09",
        "4":"/u56db",
        "5":"/u4e94",
        "6":"/u516d",
    }
    if(/(y+)/.test(fmt)){
        fmt = fmt.replace(RegExp.$1,((date.getFullYear()+"").substr(4-RegExp.$1.length)))
    }
    if(/(E+)/.test(fmt)){

    }
    for(let key in o){
        if(new RegExp('('+key+')').test(fmt)){
            fmt = fmt.replace(RegExp.$1,(RegExp.$1.length == 1) ? (o[key]) : (("00"+o[key]).substr((""+o[key]).length)));
        }
    }
    return fmt
}   

export {getHeight,dateFormater}